package com.oscarmovie.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.oscarmovie.Constants;
import com.oscarmovie.model.Audio;
import com.oscarmovie.model.Language;
import com.oscarmovie.service.AudioService;
import com.oscarmovie.service.LanguageService;

public class AudioAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private AudioService audioService;
	
	private Audio audio;
	private List<Audio> audios;
	


	public String execute() throws Exception {
		throw new Exception("Please specify method name!");
	}

	public String save() throws Exception {
		audioService.save(audio);
		return edit();
	}

	public String load() throws Exception {
		this.setAudio(audioService.load(audio.getId()));
		return SUCCESS;
	}
	public String add() throws Exception {
		setAudio(null);
		return Constants.ADD;
	}
	public String edit() throws Exception {
		loadAll();
		load();
		return Constants.EDIT;
	}
	public String loadAll() throws Exception {
		this.audios = audioService.loadAll();
		return SUCCESS;
	}
	public String select() throws Exception {
		loadAll();
		return Constants.SELECT;
	}
	public List<Audio> getAudios() {
		return audios;
	}

	public void setAudioService(AudioService audioService) {
		this.audioService = audioService;
	}

	public void setAudio(Audio audio) {
		this.audio = audio;
	}

	public Audio getAudio() {
		return audio;
	}



}
